﻿#pragma once
#include <glad/glad.h>
#include <memory>

namespace DYGraphics
{
	enum class _declspec(dllexport) TextureWrapMode
	{
		ClampToBorder = GL_CLAMP_TO_BORDER,
	};

	enum class _declspec(dllexport) TextureFilterMode
	{
		Linear = GL_LINEAR,
	};

	enum class _declspec(dllexport) TextureFormat
	{
		RGBA = GL_RGBA,
		RGB = GL_RGB,
	};

	class _declspec(dllexport) Texture2D
	{
	public:
		Texture2D();
		Texture2D(int width, int height);
		Texture2D(int width, int height, TextureFormat format);
		unsigned int GetPixelSize() const;
		void Apply(bool pKeepData = false);
		~Texture2D();
	public:
		int GetId() const { return mID; }

		void SetData(unsigned char* pData)
		{
			mData = pData;
		}

		void SetWrapMode(TextureWrapMode mode)
		{
			mWrapMode = mode;
		}

		void SetFilterMode(TextureFilterMode mode)
		{
			mFilterMode = mode;
		}

		void SetTextureFormat(TextureFormat format)
		{
			mFormat = format;
		}
	private:
		unsigned int mID;
		int mWidth;
		int mHeight;
		unsigned char* mData;

		TextureFormat mFormat;
		TextureWrapMode mWrapMode;
		TextureFilterMode mFilterMode;
	};

	typedef std::shared_ptr<Texture2D> Texture2DPtr;
}